#ifndef __FM17550_H__
#define __FM17550_H__


#include "stdint.h"


/*****************REG PAGE 0***********************/
#define CommandReg			0x01
#define ComIEnReg			0x02
#define DivIEnReg			0x03
#define ComIrqReg			0x04
#define DivIrqReg			0x05
#define ErrorReg			0x06
#define Status1Reg			0x07
#define Status2Reg			0x08
#define FIFODataReg			0x09
#define FIFOLevelReg		0x0A
#define WaterLevelReg		0x0B
#define ControlReg			0x0C
#define BitFramingReg		0x0D
#define CollReg				0x0E
/*****************REG PAGE 1***********************/
#define ModeReg				0x11
#define TxModeReg 			0x12
#define RxModeReg 			0x13
#define TxControlReg 		0x14
#define TxAutoReg 			0x15
#define TxSelReg 			0x16
#define RxSelReg 			0x17
#define RxThresholdReg 		0x18
#define DemodReg 			0x19
#define MfTxReg 			0x1C
#define MfRxReg 			0x1D
#define SerialSpeedReg 		0x1F
/*****************REG PAGE 2***********************/
#define CRCMSBReg 			0x21
#define CRCLSBReg 			0x22
#define ModWidthReg 		0x24
#define GsNOffReg 			0x23
#define TxBitPhaseReg 		0x25
#define RFCfgReg 			0x26
#define GsNReg 				0x27
#define CWGsPReg 			0x28
#define ModGsPReg 			0x29
#define TModeReg 			0x2A
#define TPrescalerReg 		0x2B
#define TReloadMSBReg 		0x2C
#define TReloadLSBReg 		0x2D
#define TCounterValMSBReg 	0x2E
#define TCounterValLSBReg 	0x2F
/*****************REG PAGE 3***********************/
#define TestSel1Reg 		0x31
#define TestSel2Reg 		0x32
#define TestPinEnReg 		0x33
#define TestPinValueReg 	0x34
#define TestBusReg 			0x35
#define AutoTestReg 		0x36
#define VersionReg 			0x37
#define AnalogTestReg 		0x38
#define TestDAC1Reg 		0x39
#define TestDAC2Reg 		0x3A
#define TestADCReg 			0x3B

#define Idle	0x00
#define Mem		0x01
#define RandomID	0x02
#define CalcCRC	0x03
#define Transmit	0x04
#define NoCmdChange	0x07
#define Receive	0x08
#define Transceive	0x0C
#define MFAuthent	0x0E
#define SoftReset	0x0F


#define ISO_Cfg_TYPE_A		0
#define ISO_Cfg_TYPE_B		1

#define CLOSE_ALL_TX		0
#define	OPEN_TX_1			1
#define OPEN_TX_2			2
#define OPEN_ALL_TX			3



extern uint8_t FM17550_PCD_TEST(void);
extern void FM17550_IO_Init(void);
extern uint8_t FM175xx_ConfigISOType(uint8_t type);
extern uint8_t FM175xx_SetTimer(unsigned long delaytime);
extern uint8_t FM175xx_Set_Rf(uint8_t mode);
extern uint8_t FM175xx_Comm(uint8_t Command, uint8_t *pInData, uint8_t InLenByte,uint8_t *pOutData, uint32_t *pOutLenBit);

extern void FM175xx_Write_Register(uint8_t addr, uint8_t dat);
extern uint8_t FM175xx_Read_Register(uint8_t addr);
extern unsigned char Clear_FIFO(void);
extern unsigned char Set_BitMask(unsigned char reg_add,unsigned char mask);
extern unsigned char Clear_BitMask(unsigned char reg_add,unsigned char mask);

extern void FM17550_RESET(void);
extern uint8_t FM175xx_SoftReset(void);

void Delay100us(uint32_t _100us);
void Delay1us(uint32_t _1us);


#endif //__FM17550_H__
